package com.lzy.cloud.order.service.impl;

import com.lzy.cloud.order.dtos.OrderRefundLogDto;
import com.lzy.cloud.order.dtos.OrderStatusHistoryDto;
import com.lzy.cloud.order.dtos.pay.OrderPayParamsDto;
import com.lzy.cloud.order.entity.OrderStatusHistory;
import com.lzy.cloud.order.mapper.OrderStatusHistoryMapperExt;
import com.lzy.cloud.order.service.OrderStatusHistoryService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 订单交易记录
 * @Author:   gyl
 * @Date:     2018/7/10 19:05
 */
@Service
public class OrderStatusHistoryServiceImpl implements OrderStatusHistoryService {

    @Autowired
    private OrderStatusHistoryMapperExt orderStatusHistoryMapperExt;

    @Override
    public List<OrderStatusHistoryDto> queryListByOrderId(String orderId) {
        return orderStatusHistoryMapperExt.queryListByOrderId(orderId);
    }

    @Override
    public OrderStatusHistoryDto find(Long id) {
        OrderStatusHistory orderStatusHistory = orderStatusHistoryMapperExt.selectByPrimaryKey(id);
        return DozerUtils.map(orderStatusHistory, OrderStatusHistoryDto.class);
    }

    @Override
    public Long create(OrderStatusHistoryDto orderStatusHistoryDto) {
        OrderStatusHistory orderStatusHistory = DozerUtils.map(orderStatusHistoryDto, OrderStatusHistory.class);
        return orderStatusHistoryMapperExt.insertSelective(orderStatusHistory)>0 ? orderStatusHistory.getId() : 0;
    }

    @Override
    public Boolean update(OrderStatusHistoryDto orderStatusHistoryDto) {
        return orderStatusHistoryMapperExt.updateByPrimaryKeySelective(DozerUtils.map(orderStatusHistoryDto, OrderStatusHistory.class)) > 0;
    }
}
